package com.own.component.netty.handler;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

/**
 * MethodMap
 *
 * @author chenxueli
 * @date 2021/4/9 17:27
 */
public class MethodMap {

    private static final Map<String, Object> PATH_BEAN_MAP = new HashMap<>();
    private static final Map<String, Method> PATH_METHOD_MAP = new HashMap<>();

    public static void add(Object bean, Map<String, Method> map) {
        PATH_METHOD_MAP.putAll(map);
        map.keySet().forEach(path -> PATH_BEAN_MAP.put(path, bean));
    }

    protected static Method getMethod(String path) {
        return PATH_METHOD_MAP.get(path);
    }

    protected static Object getBean(String path) {
        return PATH_BEAN_MAP.get(path);
    }

}
